import { request } from '@/utils/axios/axios'
import type { AttrGroupResponse, AttrGroupVo, PageNationParams } from '@/api/attr-group/type'

enum API {
  ATTR_GROUP = 'attrgroup',
}

// 保存属性分组请求
export const addAttrGroupRequest = (data: AttrGroupVo): Promise<string> => {
  return request.post<AttrGroupVo, string>(API.ATTR_GROUP, data)
}
// 分页查询属性分组
export const pageNationRequest = (
  pageNationParams: PageNationParams,
): Promise<AttrGroupResponse> => {
  return request.get<PageNationParams, AttrGroupResponse>(API.ATTR_GROUP, {
    params: pageNationParams,
  })
}
// 根据id查询属性分组信息
export const getAttrGroupByIdRequest = (attrGroupId: number): Promise<AttrGroupVo> => {
  return request.get<number, AttrGroupVo>(API.ATTR_GROUP + `/${attrGroupId}`)
}
// 修改属性分组请求
export const updateAttrGroupRequest = (data: AttrGroupVo) => {
  return request.put<AttrGroupVo, number>(API.ATTR_GROUP, data)
}
export const deleteAttrGroupRequest = (attrGroupIds: number[]) => {
  return request.delete(API.ATTR_GROUP, { data: attrGroupIds })
}
